/*
 * @Author: 噜噜雯雯 2199987619@qq.com
 * @Date: 2025-05-28 11:29:08
 * @LastEditors: 噜噜雯雯 2199987619@qq.com
 * @LastEditTime: 2025-06-18 09:09:06
 * @FilePath: \linePatrol\vue-element-plus-admin\src\api\linePatrol\index.ts
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import service from '@/axios/http'
import { TableIResponse } from '@/utils/Api'
import {
  StateInfoList,
  SendTasklistType,
  GetPlanGroupType,
  PatrolInspectionType,
  FacTaskListType,
  ScheduleSendTaskDetailType
} from './type'
export class PlanGroupApi {
  //查询巡查组列表
  async FacTasklist(params: GetPlanGroupType): Promise<TableIResponse<FacTaskListType[]>> {
    const result = (await service.get('/api/patrol/facTask/list', { params })) as unknown as any
    return result
  }
  //查询所有巡检点
  async FacTaskListAll(): Promise<FacTaskListType[]> {
    const result = (await service.get('/api/patrol/facTask/listAll')) as unknown as any
    return result.data
  }
  //删除巡检计划列表
  async DeletfacTask(ids: string): Promise<boolean> {
    const result = (await service.delete(`/api/patrol/facTask/${ids}`)) as unknown as any
    const { code } = result as any
    if (code == 200) {
      return true
    } else {
      return false
    }
  }
  //查询所选巡查点
  async GetTaskIdList(
    params: PatrolInspectionType
  ): Promise<TableIResponse<PatrolInspectionType[]>> {
    const result = (await service.get('/api/patrol/patrolInspection/getTaskIdList', {
      params
    })) as unknown as any
    return result
  }
  //查询未选巡查点
  async getTaskIdNotList(
    params: PatrolInspectionType
  ): Promise<TableIResponse<PatrolInspectionType[]>> {
    const result = (await service.get('/api/patrol/patrolInspection/getTaskIdNotList', {
      params
    })) as unknown as any
    return result
  }
  //新增巡查组
  async AddPlanGroupData(data: FacTaskListType): Promise<boolean> {
    const result = (await service.post('/api/patrol/facTask', data)) as unknown as any
    const { code } = result as any
    if (code == 200) {
      return true
    } else {
      return false
    }
  }
  //删除巡查组中巡查点的信息
  async DelTaskData(data: GetPlanGroupType): Promise<boolean> {
    const str = `/api/patrol/patrolInspection/delTaskData?taskId=${data.taskId}&uuid=${data.uuid}`
    const result = (await service.delete(str)) as unknown as any
    const { code } = result as any
    if (code == 200) {
      return true
    } else {
      return false
    }
  }
  //修改巡查组
  async EditPlanGroupData(data: FacTaskListType): Promise<boolean> {
    const result = (await service.put('/api/patrol/facTask', data)) as unknown as any
    const { code } = result as any
    if (code == 200) {
      return true
    } else {
      return false
    }
  }
  //查询巡检计划列表
  async SendTasklist(params: GetPlanGroupType): Promise<TableIResponse<SendTasklistType[]>> {
    const result = (await service.get('/api/schedule/sendTask/list', { params })) as unknown as any
    return result
  }
  //删除巡检计划
  async DeletSendTask(uuid: string): Promise<boolean> {
    const result = (await service.delete(`/api/schedule/sendTask/${uuid}`)) as unknown as any
    const { code } = result as any
    if (code == 200) {
      return true
    } else {
      return false
    }
  }
  //查询巡检任务列表
  async GetStateInfoList(params: GetPlanGroupType): Promise<TableIResponse<StateInfoList[]>> {
    const result = (await service.get('/api/patrol/planList/stateInfoList', {
      params
    })) as unknown as any
    return result
  }
  //下发巡检计划详细信息
  async GetScheduleSendTask(uuid: string | undefined): Promise<ScheduleSendTaskDetailType> {
    const result = (await service.get(`/api/schedule/sendTask/${uuid}`)) as unknown as any
    const { code, data } = result as any
    if (code == 200) {
      return data
    } else {
      return {}
    }
  }
  //新增下发巡检计划
  async AddSendTaskData(data): Promise<boolean> {
    const result = (await service.post('/api/schedule/sendTask', data)) as unknown as any
    const { code } = result as any
    if (code == 200) {
      return true
    } else {
      return false
    }
  }
  //修改下发巡检计划
  async EditSendTaskData(data): Promise<boolean> {
    const result = (await service.put('/api/schedule/sendTask', data)) as unknown as any
    const { code } = result as any
    if (code == 200) {
      return true
    } else {
      return false
    }
  }
  //修改运行的状态
  async EditSendTaskState(data: GetPlanGroupType): Promise<boolean> {
    const result = (await service.put(
      '/api/schedule/sendTask/changeStatus',
      data
    )) as unknown as any
    const { code } = result as any
    if (code == 200) {
      return true
    } else {
      return false
    }
  }
}
export default new PlanGroupApi()
